package model

import (
	"time"
)

// ImportRecord 任务数据导入记录表
type ImportRecord struct {
	BaseModel               // 继承公共字段
	TaskID       int        `gorm:"column:TASK_ID;not null;index;comment:关联任务ID（外键）" json:"task_id"`
	ImportType   string     `gorm:"column:IMPORT_TYPE;not null;size:20;comment:导入方式（direct/preprocess）" json:"import_type"`
	DataCount    int        `gorm:"column:DATA_COUNT;comment:导入数据总量" json:"data_count,omitempty"`
	SuccessCount int        `gorm:"column:SUCCESS_COUNT;comment:成功导入数量" json:"success_count,omitempty"`
	FailCount    int        `gorm:"column:FAIL_COUNT;comment:失败数量" json:"fail_count,omitempty"`
	Status       string     `gorm:"column:STATUS;not null;size:20;comment:导入状态（processing/success/failed）" json:"status"`
	ErrorLog     string     `gorm:"column:ERROR_LOG;type:text;comment:错误日志" json:"error_log,omitempty"`
	StartTime    *time.Time `gorm:"column:START_TIME;type:DATETIME;comment:开始时间" json:"start_time,omitempty"`
	EndTime      *time.Time `gorm:"column:END_TIME;type:DATETIME;comment:结束时间" json:"end_time,omitempty"`

	// 外键关联（序列化时忽略）
	Task Task `gorm:"foreignKey:TaskID;references:ID;constraint:OnDelete:CASCADE" json:"-"`
}

func (ImportRecord) TableName() string {
	return "IMPORT_RECORDS"
}
